﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Practices.Unity;
using System.Windows.Interop;

using Idlesoft.Interop;

using Idlesoft.ShellAnywhere.ViewModel;
namespace Idlesoft.ShellAnywhere.View
{
	/// <summary>
	/// Interaction logic for ShellAnywhereView.xaml
	/// </summary>
	public partial class ShellAnywhereView : Window
	{
		#region ctors
		public ShellAnywhereView() { }//{ InitializeComponent(); }
		#endregion ctors

		#region props
		[Dependency]
		public ShellAnywhereViewModel ViewModel
		{
			set 
			{ 
				DataContext = _ViewModel = value;

				SourceInitialized				+= _ViewModel.OnSourceInitialized;
				Closed							+= _ViewModel.OnClosed;

				//_ViewModel.ResetColumns = () =>
				//{
				//    DoResetColumns(_ActionsListView.View as GridView);
				//    DoResetColumns(_OutputListView.View as GridView);
				//};

			}
		}
		#endregion props

		#region methods
		private void DoResetColumns(GridView view)
		{
			if (view != null)
			{
				foreach (var column in view.Columns)
				{
					if (double.IsNaN(column.Width))
						column.Width = column.ActualWidth;
					column.Width = double.NaN;
				}
			}
		}
		#endregion methods

		#region events
		#endregion events

		#region fields
		private ShellAnywhereViewModel _ViewModel;
		#endregion fields
	}
}
